package com.zl.zlproject.ui.product.fragment;


import android.content.Intent;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.zl.zlproject.R;
import com.zl.zlproject.base.application.MyApplication;
import com.zl.zlproject.base.fragment.BaseFragment;
import com.zl.zlproject.splash.SplashActivity;
import com.zl.zlproject.utils.SpUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by 郑磊 on 2018/5/27.
 */

public class ProductFragment extends BaseFragment {
    @BindView(R.id.iv_back)
    ImageView mIvBack;
    @BindView(R.id.tv_title)
    TextView mTvTitle;
    @BindView(R.id.toolbar)
    Toolbar mToolbar;



    @Override
    protected int getContentLayoutId() {
        return R.layout.fragment_product;
    }

    @Override
    protected void initView() {
        super.initView();
        initToolbar(mToolbar, mIvBack, false);


    }

    @Override
    protected void initListener() {
        super.initListener();

    }


    private void changeSkin(int skinColor) {
        if(skinColor ==  MyApplication.appColor){
          return;
        }
        SpUtils.setInt(mContext,"appColor",skinColor);
        MyApplication.appColor =skinColor;
        Intent intent =new Intent(mContext, SplashActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK);
        mContext.startActivity(intent);
        getActivity().finish();
    }



    @OnClick({R.id.btn, R.id.btn_green, R.id.btn_red, R.id.btn_yellow, R.id.btn_blue})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn:

                changeSkin(R.color.colorPrimary);
                break;
            case R.id.btn_green:
                changeSkin(R.color.colorPrimary_green);
                break;
            case R.id.btn_red:
                changeSkin(R.color.colorPrimary_red);
                break;
            case R.id.btn_yellow:
                changeSkin(R.color.colorPrimary_yellow);
                break;
            case R.id.btn_blue:
                changeSkin(R.color.colorPrimary_blue);
                break;
        }
    }
}
